package com.yucc.girlimages.ad;

import android.content.Context;

import com.uucun.adsdk.UUAppConnect;
import com.uucun.adsdk.UpdatePointListener;

public class AppJoyAd extends AdPlatformAdapter<UUAppConnect> implements UpdatePointListener {
	private static AppJoyAd sInstance ;
	private static Object sLock = new Object() ;
	
	private AppJoyAd(Context context) {
		super();
		UUAppConnect.getInstance(context).initSdk() ;
	}
	
	public static final AppJoyAd getInstance(Context context) {
		synchronized (sLock) {
			if(sInstance == null) {
				sInstance = new AppJoyAd(context) ;
			}
		}
		return sInstance ;
	}

	@Override
	public UUAppConnect getAdInstance(Context context) {
		// TODO Auto-generated method stub
		return UUAppConnect.getInstance(context);
	}

	@Override
	public void onError(String error) {
		// TODO Auto-generated method stub
		if(failureCallBack != null) failureCallBack.getPointFailure(error) ;
	}

	@Override
	public void onSuccess(String currenyName, int amount) {
		if(successCallBack != null) successCallBack.getPointSuccess(currenyName, amount) ;
	}

	@Override
	public void showOffers(Context context) {
		getAdInstance(context).showOffers() ;
	}

	@Override
	public void free(Context context) {
		getAdInstance(context).exitSdk() ;
	}

	@Override
	public void spendPoints(Context context,float point) {
		getAdInstance(context).spendPoints((int)point, this) ;
	}

	@Override
	public void getPoints(Context context) {
		getAdInstance(context).getPoints(this) ;
	}

}
